Skip to content

[css-borders-4] Define border/shadow rendering for corner-shape #12175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

noamr
Copy link
Collaborator

@noamr noamr commented May 8, 2025

Based on this resolution

  • Borders are rendered perpendicular to the outer curve, clamped at corner-shape -1 or 1.
  • Shadows are rendered like a scaled version of the original shape, converting the shadow spread to a scale.

Added detailed algorithms, explanation, and a chart.

Closes #11610
Closes #11767

@noamr noamr requested review from smfr and tabatkins May 8, 2025 08:34
Copy link
Member

@tabatkins tabatkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specific comments scattered in. Generally, tho, I can't actually follow the algorithm and am confused by several details, and it handwaves several operations that might be obvious when you're "in the code", but aren't clear from my perspective as a relative outsider.

1. If |s| is equal or less than -1, return <code>0, -|w|</code>.

Note: Because of the above clamping, when the shape is more convex than a ''corner-shape/round'' or more concave than a ''corner-shape-scoop'',
the inner curve cannot would appear to have a "belly" towards the middle, as it cannot remain constant while maintaining the same curvature.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"cannot would" needs fixing, but I'm not 100% certain what it's trying to say.

To compute the inner path of a corner:

1. Let |adjustedX|, |adjustedY| be the result of the [=adjusted untrimmed inner top-left corner starting point=] steps,
modified to consider the corresponding 'border-width' and 'corner-shape' values at the start and end of a path`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the modification?


1. Let |adjustedX|, |adjustedY| be the result of the [=adjusted untrimmed inner top-left corner starting point=] steps,
modified to consider the corresponding 'border-width' and 'corner-shape' values at the start and end of a path`.
1. Create a path based on the [=canonical superellipse formula=], with the outer corner as the center, starting from |adjustedX| and ending at |adjustedY|.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand what this is saying. I'm particularly confused by what the "starting from... ending from..." part means; it doesn't match what I thought those variables were for. They're x and y coordinates of a point; how do you "start" and "end" at them individually?

modified to consider the corresponding 'border-width' and 'corner-shape' values at the start and end of a path`.
1. Create a path based on the [=canonical superellipse formula=], with the outer corner as the center, starting from |adjustedX| and ending at |adjustedY|.
User agents MAY create an approximation of this path rather than try to follow the formula precisely, for performance reasons.
1. Trim the resulting path so that it starts at a point that has a 'border-width' distance from the outer.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also not sure what this is actually telling me to do. :(


This is illustrated in the following chart:
<figure>
<img src="images/corner-shape-border.svg"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could use some details of where the points/etc calculated by the above algorithms are.

Is the hull calculated in the above algorithms in some way?

@noamr
Copy link
Collaborator Author

noamr commented Jun 2, 2025

Specific comments scattered in. Generally, tho, I can't actually follow the algorithm and am confused by several details, and it handwaves several operations that might be obvious when you're "in the code", but aren't clear from my perspective as a relative outsider.

Fair! I redid the whole thing with more explanations and a rigorous algorithm. PTAL!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[css-borders-4] specify how corner-shape affects shadows, outline etc [css-borders-4] Specify how borders are rendered for corner-shape
2 participants